package com.hqyj.common.dao;

import com.hqyj.common.pojo.TestPaper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import org.apache.ibatis.annotations.Mapper;
import org.springframework.context.annotation.Bean;

import java.util.List;


import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 试卷 Mapper 接口
 * </p>
 *
 * @author j0701-9
 * @since 2021-10-20
 */
public interface TestPaperMapper extends BaseMapper<TestPaper> {


    List<TestPaper> selectTestPaperByUserId(Integer userId);
    @Bean
    List<TestPaper> selectAll();


    @Select("SELECT " +
            "test_paper_id,test_paper_name,select_topic,multiple_topic," +
            "judge_topic,short_topic,ready_class,start_time,end_time," +
            "handler,status" +
            " from test_paper where test_paper_name = #{testPaperName}")
    TestPaper selectTestPaperByTestPaperName(String testPaperName);

    @Select("SELECT " +
            "test_paper_id,test_paper_name,select_topic,multiple_topic," +
            "judge_topic,short_topic,ready_class,start_time,end_time," +
            "handler,status" +
            " from test_paper where ready_class = #{clazz}")
    TestPaper selectTestPaperByClazz(String clazz);

    @Select("SELECT " +
            "test_paper_id,tp.test_paper_name,select_topic,multiple_topic," +
            "judge_topic,short_topic,ready_class,start_time,end_time," +
            "handler,status" +
            " from test_paper tp INNER JOIN result r " +
            "on tp.ready_class = r.clazz where r.examinee_id = #{userId} " +
            "and tp.test_paper_name like #{keyword};")
    List<TestPaper> selectTestPaperByUserIdAndKeyword(Integer userId, String keyword);

}
